package org.jerrymouse.jsa4j.db.kv.example;

import org.jerrymouse.jsa4j.db.kv.DB;
import org.jerrymouse.jsa4j.db.kv.DBManagerFactory;
import org.jerrymouse.jsa4j.db.kv.Repository;

public class Tutorial {

	private static DB db;

	private static String EXAMPLE = "example";

	private static DB getDB() {
		if (db == null)
			db = new DBManagerFactory().getDBManager("derby-db").getDB();
		return db;
	}

	public static Repository getRepository(String prefix) {
		Repository repository = new Repository(prefix, getDB());
		return repository;
	}

	public static void main(String[] args) {
		getRepository(EXAMPLE).put("1", "hello jsa4j");
		String message = getRepository(EXAMPLE).get("1");
		System.out.println(message);
	}
}
